<?php
class sendmailController extends CController {
    
    function __construct()
    {
        parent::__construct();
    }
    
    function on_main()
    {
        $tpl_data['title'] = '邮件测试';
        $this->display('sendmail',$tpl_data);
    }
    
    function on_send()
    {
        //发送邮件测试
        Nimo::import('CMail');
        $mailer = new CMail(CConf::get('email'));
        $toaddress[$_POST['toaddress']['name']] = $_POST['toaddress']['email'];
        $mailer->send($toaddress, $_POST['subject'], $_POST['body'], $_POST['charset'], '1');
        
        //Nimo::import('CUpload');
        //$uploader = new CUpload();
        //$res = $uploader->setFile($_FILES['attachs']);
        //$res && $res = $uploader->setRootDir('data/uploadfiles/');
        //$res && $res = $uploader->save();
        //if (!$res) {
        //	var_dump($uploader->_errorCode);
        //} else {
        //    var_dump('success');
        //}
    }
}